import { ApiProperty } from '@nestjs/swagger'
import { Transform } from 'class-transformer'
import { IsEnum, IsNumber, IsOptional, IsString } from 'class-validator'
import { OcrTaskStatus, OcrTaskType } from '../interfaces/ocr.interface'

export class OcrQueryDto {
  @ApiProperty({ description: '页码', required: false, default: 1 })
  @IsNumber()
  @IsOptional()
  @Transform(({ value }) => parseInt(value, 10))
  page?: number = 1

  @ApiProperty({ description: '每页数量', required: false, default: 10 })
  @IsNumber()
  @IsOptional()
  @Transform(({ value }) => parseInt(value, 10))
  pageSize?: number = 10

  @ApiProperty({ description: '任务URL', required: false })
  @IsString()
  @IsOptional()
  url?: string

  @ApiProperty({ description: '任务ID', required: false })
  @IsString()
  @IsOptional()
  taskId?: string

  @ApiProperty({ description: '任务类型', required: false, enum: OcrTaskType })
  @IsEnum(OcrTaskType)
  @IsOptional()
  @Transform(({ value }) => parseInt(value, 10))
  taskType?: OcrTaskType

  @ApiProperty({ description: '任务状态', required: false, enum: OcrTaskStatus })
  @IsEnum(OcrTaskStatus)
  @IsOptional()
  @Transform(({ value }) => parseInt(value, 10))
  status?: OcrTaskStatus
}
